/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package study.alex.avalon;

import java.util.SortedMap;
import java.util.TreeMap;

/**
 *
 * @author RERIR
 */
public class SimpleSimularMap<T,S> extends TreeMap<T,S> implements CanDetermineSimularity<T> {
    

    @Override
    public boolean lookFor(T match) {
        return ceilingKey(match) == null ? false : true;
                
    }

    @Override
    public T lookSimular(T match) {
        return ceilingKey(match);
    }

    @Override
    public int diff(T match, T key) {
        String sMatch = match.toString();
        String sKey = key.toString();
        int score = sKey.indexOf(sMatch);
        if (score <0) return 0;
        return score+sMatch.length();
    }
}
